#ifndef KPEXTCOMMONDEF_H
#define KPEXTCOMMONDEF_H

#include <iostream>
#include <sstream>
#include <fstream>
#include <memory>
#include <limits>
#include <string>
#include <iterator>
#include <iomanip>
#include <array>
#include <vector>
#include <set>
#include <unordered_map>
#include <chrono>  //  高精度计时库
#include <thread>
#include <mutex>

//#include "fmt/src/format.cc"  // 定义了 FMT_HEADER_ONLY 才需要
#include "fmt/core.h"
#include "fmt/ranges.h"
#include "fmt/color.h"


#ifndef KPEXT_NO_SPDLOG
#   include "spdlog/spdlog.h"
#   include "spdlog/sinks/rotating_file_sink.h"
#   include "spdlog/sinks/stdout_color_sinks.h"
#else
#   ifndef SPDLOG_ACTIVE_LEVEL
#       define SPDLOG_TRACE(...)
#       define SPDLOG_DEBUG(...)
#       define SPDLOG_INFO(...)
#       define SPDLOG_WARN(...)
#       define SPDLOG_ERROR(...)
#       define SPDLOG_CRITICAL(...)
#   else
#       define SPDLOG_TRACE(...) fmt::print("[TRACE] : {}\n", fmt::format(__VA_ARGS__))
#       define SPDLOG_DEBUG(...) fmt::print("[DEBUG] : {}\n", fmt::format(__VA_ARGS__))
#       define SPDLOG_INFO(...) fmt::print("[INFO] : {}\n", fmt::format(__VA_ARGS__))
#       define SPDLOG_WARN(...) fmt::print("[WARN] : {}\n", fmt::format(__VA_ARGS__))
#       define SPDLOG_ERROR(...) fmt::print("[ERROR] : {}\n", fmt::format(__VA_ARGS__))
#       define SPDLOG_CRITICAL(...) fmt::print("[CRITICAL] : {}\n", fmt::format(__VA_ARGS__))
#       if SPDLOG_ACTIVE_LEVEL > 0
#           undef SPDLOG_TRACE
#           define SPDLOG_TRACE(...)
#       endif
#       if SPDLOG_ACTIVE_LEVEL > 1
#           undef SPDLOG_DEBUG
#           define SPDLOG_DEBUG(...)
#       endif
#       if SPDLOG_ACTIVE_LEVEL > 2
#           undef SPDLOG_INFO
#           define SPDLOG_INFO(...)
#       endif
#       if SPDLOG_ACTIVE_LEVEL > 3
#           undef SPDLOG_WARN
#           define SPDLOG_WARN(...)
#       endif
#       if SPDLOG_ACTIVE_LEVEL > 4
#           undef SPDLOG_ERROR
#           define SPDLOG_ERROR(...)
#       endif
#       if SPDLOG_ACTIVE_LEVEL > 5
#           undef SPDLOG_CRITICAL
#           define SPDLOG_CRITICAL(...)
#       endif
#   endif // SPDLOG_ACTIVE_LEVEL
#endif // KPEXT_NO_SPDLOG


#ifdef KPEXT_USE_KOMPUTE

#include "kompute/Core.hpp"
#include "kompute/Tensor.hpp"
#include "kompute/Manager.hpp"
#include "kompute/Algorithm.hpp"
#include "kompute/Sequence.hpp"
#include "kompute/operations/OpTensorSyncLocal.hpp"
#include "kompute/operations/OpTensorSyncDevice.hpp"
#include "kompute/operations/OpMemoryBarrier.hpp"

#else

//#include "vulkan/vulkan.h"
#include "vulkan/vulkan.hpp"

#endif


//#define GLM_FORCE_RADIANS   // 强制glm库使用弧度
//#define GLM_FORCE_DEPTH_ZERO_TO_ONE  //  由于vulkan与opengl深度范围不一样，它是0~1.0的
//#include "glm/glm.hpp"
//#include "glm/gtc/matrix_transform.hpp"


#include "nlohmann/json.hpp"  //  不知道为什么，这个inclue会报找不到头文件
//#include "../nlohmann-json/single_include/nlohmann/json.hpp"

#include "kpextSpvData.h"

#define UNUSE_VAR(x) (void)x

#define STCAST_ASSIGN(y, x) y = static_cast<decltype(y)>(x)

#define BITCAST_ASSIGN(y, x) (*reinterpret_cast<decltype(x) *>(reinterpret_cast<void *>(& y))) = x

extern bool IS_CONSOLE_SUPORT_COLOR;

#endif // KPEXTCOMMONDEF_H
